package com.niit.EachTypeMovieNumber;

import com.niit.PublicClass.getSimpleQuotationInfo;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;
import java.util.ArrayList;
import java.util.TreeMap;

// map阶段
// KEYIN: 输入数据的key的类型

public class ETMNMapper extends Mapper<LongWritable, Text, Text, IntWritable> {
    private final static IntWritable valueOut = new IntWritable(1);
    Text keyOut = new Text();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        String line = value.toString();

        String[] movies = line.split("\t");


        // 3. 封装数据
//        String rate = movies[0];
//        String rank = movies[1];
          String types = movies[2];
//        System.out.println(types);
//        String regions = movies[3];
//        String title = movies[4];
          String release_data = movies[5];
//        String actor_count = movies[6];
//        String vote_count = movies[7];
//        String score = movies[8];
//        String actors = movies[9];
        getSimpleQuotationInfo gSQI = new getSimpleQuotationInfo();
        ArrayList<String> type = gSQI.getInfo(types);
        for (String info : type) {
            keyOut.set(info);

            context.write(keyOut, valueOut);
        }

    }
}

